﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArchMethodLibrary.ColumnProfileAnalyze;
using YJKRGeometry;
using TopologySearch;

namespace ModelValidation.ShapeCoefficientOfBuilding
{
	internal class Utility
	{
		public static Pole2D GetPole2D(Wall wall)
		{
			return Pole2D.TransformWallToStructure2DPole(wall);
		}

		public static List<Pole2D> GetPole2D(ColumnProfileAnalyzer columnAnalyzer, FamilyInstance column)
		{
			List<Pole2D> list = new List<Pole2D>();
			List<ColumnProfileInfo> list2 = new List<ColumnProfileInfo>();
			XYZ point = (column.Location as LocationPoint).Point;
			foreach (Solid solid in columnAnalyzer.GetElementSolids(column))
			{
				list = columnAnalyzer.GetSolidProfile(point, solid, column.Id, ref list2);
			}
			if (list == null)
			{
				return null;
			}
			return list;
		}

		public static List<List<Curve>> GetLoop(Autodesk.Revit.DB.Document doc, List<Pole2D> pole2DList)
		{
			return new StructureLoopSearcher(doc).GetFullFloorEdgeLoops(pole2DList, StructureLoopSearcher.SearchEdgeLocation.SEL_Outside);
		}

		public static double GetGirth(List<List<Curve>> loops)
		{
			double num = 0.0;
			foreach (List<Curve> list in loops)
			{
				foreach (Curve curve in list)
				{
					double length = curve.Length;
					num += length;
				}
			}
			return num;
		}

		public static double GetArea(List<List<Curve>> loops)
		{
			double num = 0.0;
			foreach (List<Curve> loops2 in loops)
			{
				double area = Utility.GetArea(loops2);
				num += area;
			}
			return num;
		}

		private static double GetArea(List<Curve> loops)
		{
			return Geometry.AoArea1(loops);
		}
	}
}
